import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { CacheQuery, CachePage, CacheForm } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getCachePage(
  queryParams: CacheQuery
): AxiosPromise<PageResult<CachePage[]>> {
  return request({
    url: "/config/yac/lst",
    method: "get",
    params: queryParams,
  });
}

export function getInfo() {
  return request({
    url: "/config/yac/index",
    method: "get",
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getCacheForm(ids: string): AxiosPromise<CacheForm> {
  return request({
    url: "/config/yac/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addCache(data: any) {
  return request({
    url: "/config/yac/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateCache(data: CacheForm) {
  return request({
    url: "/config/yac/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteCache(data: any) {
  return request({
    url: "/config/yac/del",
    method: "delete",
    data,
  });
}

export function clearCache() {
  return request({
    url: "/config/yac/clear",
    method: "delete",
  });
}
